#include "task_runnable.h"
#include <stdint.h>

using namespace NetKit;

TaskRunnable::
TaskRunnable(Processor* pProcessor, Request* pRequest, Response* pResponse, int sock_pair_fd)
{
	m_pProcessor = pProcessor;
	m_pRequest = pRequest;
	m_pResponse = pResponse;
	m_sock_pair_fd = sock_pair_fd;
}

void TaskRunnable::run()
{
	m_pProcessor->HandleRequest(m_pRequest, m_pResponse);

	int8_t b = 0;
	if (-1 == write(m_sock_pair_fd, &b, sizeof(int8_t))) 
	{
      		perror("TaskRunnable: send :");
	}
    	if ( -1 == close(m_sock_pair_fd) ) 
	{
      		perror("TaskRunnable: close, possible resource leak: ");
    	}
}

